package services

import (
	"hft/Database/admin"
	"hft/Http/Models/dao"
	"hft/Http/Models/request"
	utils "hft/Http/Utils"
	"hft/global"
)

type Advise struct{}

func (*Advise) Add(data *admin.Advise) (err error) {

	global.OC_DB.Create(&data)

	return nil
}

func (*Advise) List(paginate *request.Advise) (page *utils.Page, err error) {

	var list []*admin.Advise
	global.OC_DB.Scopes(dao.AdviseDao.List(paginate, global.OC_DB)).Find(&list).Scopes(dao.GetCount(global.OC_DB)).Count(&paginate.Total)
	paginate.Data = list
	return &paginate.Page, nil
}

var AdviseService = new(Advise)
